package com.demo.spark.sql;

import org.apache.spark.sql.SparkSession;
import org.apache.spark.sql.hive.HiveContext;

public class DataSetHiveSuport {
    public static void main(String[] args) {

        SparkSession spark_support_hive = SparkSession.builder().appName("spark support hive")
                .config("spark.sql.warehouse.dir", "/user/spark")
                .config("hive.metastore.uris","thrift://hadoop-1:9083")
                .master("local")
                .enableHiveSupport()
                .getOrCreate();
        spark_support_hive.sql("show tables").show();
        spark_support_hive.sql("create table if not exists person (name STRING, age INT) USING hive");
        spark_support_hive.sql("insert into person values('zhangsan',21)");

        spark_support_hive.sql("select * from person").show();

    }

}
